package serviceImp;

import entity.hotel_employee;
import mapper.HotelEmployeeMapper;
import service.HotelEmployeeService;

import java.util.List;

public class HotelEmployeeServiceImp implements HotelEmployeeService {
    private HotelEmployeeMapper hotelEmployeeMapper = new HotelEmployeeMapper();
    public int register(String tel,String password){
        if(hotelEmployeeMapper.selectByTel(tel,password)!=null){
            return -1;
        }else {
            return hotelEmployeeMapper.insert(tel,password);
        }
    }

    public int login(String tel,String password){
        hotel_employee hotel_employee = hotelEmployeeMapper.selectByTel(tel,password);
        if(hotel_employee==null){
            //账号不存在
            return -1;
        }else if(hotel_employee.getEmployee_password().equals(password)){
            //登陆成功
            return 1;
        }else {
            //登陆失败，密码错误
            return 0;
        }
    }

    @Override
    public List<hotel_employee> employeesInfo() {
        return hotelEmployeeMapper.selectAll();
    }

    @Override
    public String selectIdByTel(String tel) {
        return hotelEmployeeMapper.selectIdByTel(tel);

    }

    @Override
    public String selectNameByTel(String tel) {
        return hotelEmployeeMapper.selectNameByTel(tel);
    }

    @Override
    public hotel_employee selectInfoByTel(String tel) {
        return hotelEmployeeMapper.selectInfoByTel(tel);
    }

    @Override
    public int employeeChangeInfo(hotel_employee hotel_employee) {
        return hotelEmployeeMapper.employeeChangeInfo(hotel_employee);
    }

    @Override
    public int employeeChangeJob(hotel_employee hotel_employee) {
        return hotelEmployeeMapper.employeeChangeJob(hotel_employee);
    }

    @Override
    public int deleteByTel(String deleteTel) {
        return hotelEmployeeMapper.deleteByTel(deleteTel);
    }
}
